package com.shuiyun.jtt.message;

import com.shuiyun.jtt.session.Session;
import lombok.NoArgsConstructor;

import java.beans.Transient;

/**
 * @author shuiyun
 * @description 交通部消息抽象类
 * @date 2022-04-17 16:11
 */
@NoArgsConstructor
public class JTMessage {

    private transient Session session;

    private Header header;

    @Transient
    public Session getSession() {
        return session;
    }

    public void setSession(Session session) {
        this.session = session;
    }

    public Header getHeader() {
        return header;
    }

    public void setHeader(Header header) {
        this.header = header;
    }

    public void setHeader(int messageId,String mobileNo,int serialNo){
        Header header = new Header();
        header.setMessageId(messageId);
        header.setMobileNo(mobileNo);
        header.setSerialNo(serialNo);
        header.setVersionNo(1);
        header.setVersion(true);
        this.header = header;
    }

    public Integer getMessageType() {
        if (null == header) {
            return null;
        }
        return header.getMessageId();
    }

    public JTMessage(Header header) {
        this.header = header;
    }

}
